package com.dubbo.consumer.service.impl;

import com.dubbo.api.entity.ContractResponse;
import com.dubbo.api.service.IContractDubboService;
import com.dubbo.consumer.entity.constant.ResponseCodeConstant;
import com.dubbo.consumer.service.IContractService;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

/**
 * @Author Gavin
 * @Date 2023/01/31 11:23
 */
@Slf4j
@Service
public class ContractServiceImpl implements IContractService {

    @DubboReference(interfaceClass = IContractDubboService.class, version = "1.0.0", check = false)
    private IContractDubboService contractDubboService;


    @Override
    public boolean genContract() {
        ContractResponse contractResponse = contractDubboService.genContract(null);
        if (contractResponse != null && ResponseCodeConstant.DUBBO_SUCCESS.equals(
                contractResponse.getResponseCode())) {
            log.info("============Dubbo response: {}============", contractResponse);
            return true;
        }
        log.error("============Error============");
        return false;
    }
}
